import java.util.Map;
import java.util.HashMap;

public class TwoSum{

	public static int[] twoSum(int[] nums, int target) {
		Map<Integer, Integer> map = new HashMap<>();
		for (int i = 0; i < nums.length; ++i) {
			if (map.containsKey(nums[i]))
			return new int[] { map.get(nums[i]), i };
			map.put(target - nums[i], i);
		}
		throw new RuntimeException("No Solution");
	}

	public static void main(String[] args){
		int[] array = {2, 5, 6, 2, 9};
		int target = 4;

		int[] result = twoSum(array, target);
		System.out.println(""+result[0]+","+result[1]);
	}
}
